#include <QWidget>
#include <QPainter>
#include "colordisplaylabel.h"

colorDisplayLabel::colorDisplayLabel(QWidget *parent = 0)
	:QLabel(parent)
{
	m_r = this->palette().background().color().red();
	m_g = this->palette().background().color().green();
	m_b = this->palette().background().color().blue();
}

void colorDisplayLabel::setRgb(quint16 r, quint16 g, quint16 b)
{
	m_r = r;
	m_g = g;
	m_b = b;
	update();
}

void colorDisplayLabel::paintEvent(QPaintEvent *event)
{
	Q_UNUSED(event);

	QPainter painter(this);
	painter.setPen(Qt::NoPen);
	painter.setRenderHints(QPainter::Antialiasing, true);
	painter.setBrush(QColor(m_r, m_g, m_b));
	painter.drawEllipse(0, 0, height() - 2, height() - 2);
}